/**
 * 访问记录模型
 */
class Visitor extends CommonModels {
    tableFields() {
        return {
            "UID": {
                "label": "用户ID",
                "type": "int(11)"
            },
            "id_card": {
                "label": "身份证",
                "type": "varchar(18)"
            },
            "building_id": {
                "label": "楼宇ID",
                "type": "int(11)"
            },
            "company_id": {
                "label": "公司ID",
                "type": "int(11)"
            },
            "type": {
                "label": "类型 1本楼人员 2邀请人员 3其他",
                "type": "int(1)",
                "defaultValue":1
            },
            "status": {
                "label": "状态 1正常 2超出预警 3标记人员",
                "type": "int(1)",
                "defaultValue":1

            },
            "lock_door_type":{
                "label": "进出类型 1进 2出",
                "type": "int(1)",
                "defaultValue":1
            },
            "note":{
                "label": "备注",
                "type": "varchar(255)"
            }
        }
    }

    rules() {
        return {

        }
    }

    tableName() {
        return '{{%visitor}}';
    }

    getUser(){
        return this.belongsTo({name:M('User').tableName(),as:'user_info'},'UID', 'id',['id','real_name','mobile','id_card']);
    }

    getBuilding() {
        return this.belongsTo({ name: M('Building').tableName(), as: 'building_info' }, 'building_id', 'id', ['id', 'name']);
    }

    getCompany() {
        return this.belongsTo({ name: M('Company').tableName(), as: 'company_info' }, 'company_id', 'id', ['id', 'name']);
    }

}

export default Visitor;